Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rbush

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rbush

High-performance 2D spatial index for rectangles (based on R*-tree with bulk loading and bulk insertion algorithms)

  • 2.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
679K
decreased by-65.34%
Maintainers
1
Weekly downloads
 
Created

What is rbush?

The rbush npm package is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. It's based on an R-tree, a data structure for spatial indexing, which allows for efficient querying of spatial data like rectangles and points. It is commonly used for tasks such as collision detection, geospatial queries, and storing spatial data efficiently.

What are rbush's main functionalities?

Inserting items

This feature allows you to insert items into the RBush tree. Each item is an object with minX, minY, maxX, and maxY properties, which define the bounding box of the item.

const RBush = require('rbush');
const tree = new RBush();
tree.insert({minX: 20, minY: 40, maxX: 30, maxY: 50, data: {id: 'item1'}});

Bulk-inserting items

This feature allows you to bulk-insert an array of items into the RBush tree, which can be more efficient than inserting them one by one.

const RBush = require('rbush');
const tree = new RBush();
tree.load([
  {minX: 20, minY: 40, maxX: 30, maxY: 50},
  {minX: 15, minY: 10, maxX: 25, maxY: 30}
]);

Searching for items

This feature allows you to search for items in the RBush tree that intersect with the given bounding box.

const RBush = require('rbush');
const tree = new RBush();
// ... after inserting items into the tree
const results = tree.search({minX: 40, minY: 20, maxX: 80, maxY: 70});

Removing items

This feature allows you to remove a previously inserted item from the RBush tree.

const RBush = require('rbush');
const tree = new RBush();
const item = {minX: 20, minY: 40, maxX: 30, maxY: 50};
tree.insert(item);
tree.remove(item);

Clearing the tree

This feature allows you to remove all items from the RBush tree, effectively clearing it.

const RBush = require('rbush');
const tree = new RBush();
tree.clear();

Other packages similar to rbush

Keywords

FAQs

Package last updated on 21 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc